package top.korori.utils;

import cn.hutool.core.util.RandomUtil;

import java.util.Random;

public class GenImage {
    private static final Random random = new Random();

    public static class ImageUrl {
        // 获取随机图片
        public static String getRandomImage(int width, int height) {
            return String.format("https://picsum.photos/%d/%d?random=%d",
                    width, height, random.nextInt(1000));
        }

        // 获取指定 ID 的图片
        public static String getImageById(int id, int width, int height) {
            return String.format("https://picsum.photos/id/%d/%d/%d",
                    id, width, height);
        }

        // 获取模糊效果的图片
        public static String getBlurImage(int width, int height, int blur) {
            return String.format("https://picsum.photos/%d/%d?blur=%d",
                    width, height, blur);
        }

        // 获取灰度效果的图片
        public static String getGrayscaleImage(int width, int height) {
            return String.format("https://picsum.photos/%d/%d?grayscale",
                    width, height);
        }
    }

    public static void main(String[] args) {
        // 使用示例
        System.out.println("随机图片: " +
                ImageUrl.getRandomImage(800, 600));

        System.out.println("指定ID图片: " +
                ImageUrl.getImageById(237, 800, 600));

        System.out.println("模糊效果图片: " +
                ImageUrl.getBlurImage(800, 600, 5));

        System.out.println("灰度效果图片: " +
                ImageUrl.getGrayscaleImage(800, 600));
    }

    public static String getAvatar(){
        int i = RandomUtil.randomInt(0, 1000);
        return ImageUrl.getImageById(i,600, 600);
    }
}
